<include file="../header" />
<body class="J_scroll_fixed">
    <script>

        $(function () {

            $('button.add').click(function () {

                layer.open({
                    type: 2,
                    title: '会员管理--添加会员',
                    maxmin: false,
                    shadeClose: true, //点击遮罩关闭层
                    area: ['80%', '98%'],
                    content: "{:U('vip/add')}"

                });
            });
            $('button.offlineOpenPre').click(function () {

                var orderId = $(this).attr("id");
                layer.open({
                    type: 2,
                    title: '线下购买开通',
                    maxmin: false,
                    shadeClose: true, //点击遮罩关闭层
                    area: ['80%', '98%'],
                    content: "{:U('vip/offlineOpenPre')}&orderId=" + orderId,
                    cancel: function (index) {
                        window.location.reload();
                    }

                });
            });
            $('button.offlineBuy').click(function () {

                var id = $(this).attr("id");
                var shopId = $(this).attr("shopId");

                layer.open({
                    type: 2,
                    title: '线下购买',
                    maxmin: false,
                    shadeClose: true, //点击遮罩关闭层
                    area: ['80%', '98%'],
                    content: "{:U('vip/offlineBuy')}&id=" + id + "&shopId=" + shopId,
                    cancel: function (index) {
                        window.location.reload();
                    }

                });
            });
            $('button.edit').click(function () {

                var id = $(this).attr("id");
                layer.open({
                    type: 2,
                    title: '会员管理--会员更新',
                    maxmin: false,
                    shadeClose: true, //点击遮罩关闭层
                    area: ['80%', '98%'],
                    content: "{:U('vip/edit')}&id=" + id,
                    cancel: function (index) {
                        window.location.reload();
                    }

                });
            });
            $('button.viewBindingCoach').click(function () {

                var id = $(this).attr("id");
                var shopId = $(this).attr("shopId");
                layer.open({
                    type: 2,
                    title: '查看绑定教练',
                    maxmin: false,
                    shadeClose: true, //点击遮罩关闭层
                    area: ['80%', '98%'],
                    content: "{:U('vip/viewBindingCoach')}&id=" + id + "&shopId=" + shopId,
                    cancel: function (index) {
                        window.location.reload();
                    }
                });
            });
            $('button.buyCourse').click(function () {

                var id = $(this).attr("id");
                var shopId = $(this).attr("shopId");
                layer.open({
                    type: 2,
                    title: '购买课程',
                    maxmin: false,
                    shadeClose: true, //点击遮罩关闭层
                    area: ['80%', '98%'],
                    content: "{:U('vip/buyCourse')}&id=" + id + "&shopId=" + shopId,
                    cancel: function (index) {
                        window.location.reload();
                    }

                });
            });
            $('button.viewAllClassRecord').click(function () {

                var id = $(this).attr("id");
                var shopId = $(this).attr("shopId");
                layer.open({
                    type: 2,
                    title: '所有课程记录',
                    maxmin: false,
                    shadeClose: true, //点击遮罩关闭层
                    area: ['80%', '98%'],
                    content: "{:U('vip/viewAllClassRecord')}&id=" + id + "&shopId=" + shopId + "&status=1"

                });
            });
            $('button.myVipRecord').click(function () {

                var id = $(this).attr("id");
                var shopId = $(this).attr('shopId');
                layer.open({
                    type: 2,
                    title: '查看会员卡开通记录',
                    maxmin: false,
                    shadeClose: true, //点击遮罩关闭层
                    area: ['80%', '98%'],
                    content: "{:U('vip/myVipRecord')}&id=" + id + "&shopId=" + shopId

                });
            });
            $('button.onlineOpen').click(function () {

                var id = $(this).attr("id");
                layer.open({
                    type: 2,
                    title: '线上购买开通',
                    maxmin: false,
                    shadeClose: true, //点击遮罩关闭层
                    area: ['80%', '98%'],
                    content: "{:U('vip/onlineOpen')}&id=" + id,
                    cancel: function (index) {
                        window.location.reload();
                    }

                });
            });
            $('button.bookCoachTime').click(function () {

                var id = $(this).attr("id");
                layer.open({
                    type: 2,
                    title: '预约教练的时间',
                    maxmin: false,
                    shadeClose: true, //点击遮罩关闭层
                    area: ['80%', '98%'],
                    content: "{:U('vip/bookCoachTime')}&courseId=" + id,
                    cancel: function (index) {
                        window.location.reload();
                    }

                });
            });

            $('button#send').click(function () {
                var finger = $('input[name=finger]').val();
                var mobile = $('input[name=mobile]').val();

                if ((finger == null || finger == '') && (mobile == null || mobile == '')) {
                    layer.msg('指纹或手机号至少有一个必填！');
                    return false;
                }
                $('form#search').submit();
            });

        });
    </script>
    <form id='search' class="well form-search" method="post" style="float:left;width:100%;" action="{:U('vip/checkVip')}">
        <div class="search_type cc mb10">
            <div class="mb10">
                <span class="mr20">
                    店铺：
                    {:getShopSelectHtml($shopId,0)}
<!--                    指纹(优先)：
                    <input type="text" name="finger" class="input" value="{$finger}" />-->
                    手机号：
                    <input type="text" name="mobile" class="input" value="{$mobile}" />                    
                    <button class="btn btn-primary search" id="send">搜索</button>
                    <a class="btn" href="{:U('vip/checkVip')}">重置</a>
                </span>
            </div>
        </div>
    </form>
<if condition="$isGet eq 1">

    <elseif condition="$vipNotExist eq 1"/>
    <center>
        <h3>用户不存在</h3>
        <div class="form-actions">
            <button class="add btn" id="">添加会员</button>
        </div>
    </center>
    <else/>
    <div class="wrap jj">
        <table class="table table-hover table-bordered">
            <tr>
                <th colspan='4'>会员的基本信息</th>
                <th colspan='1'>
                    <button class="edit btn" id="{$vip['vip_id']}">修改</button>
                </th>
            </tr>
            <tr>
                <td width='10%'>姓名</td>
                <td width='25%'>{$vip.vip_name}</td>
                <td width='10%'>性别</td>
                <td width='25%'>{:getEnumString($gender,$vip['gender'])}</td>
                <td rowspan='3' width='10%'>
                    <div class="controls">
                        <img src="/Uploads/VipImg/{$vip.head_image_url}" style="height:100px;width:100%;"/>
                    </div>
                </td>

            </tr>
            <tr>
                <td>生日</td>
                <td>{$vip.birthday}</td>
                <td>身份证号</td>
                <td >{$vip.idcard_number}</td>        
            </tr>
            <tr>
                <td>创建时间</td>
                <td>{$vip.create_time}</td>
                <td>手机号</td>
                <td>{$vip.mobile}</td>          
            </tr>
        </table>
        <if condition="$status eq 0">
            <table class="table table-hover table-bordered">
                <tr>
                    <th colspan='2'>店铺与会员卡信息</th>
                </tr>
                <tr>
                    <td>会员卡状况</td>
                    <td>
                        <span style="color: red;">未购买会员卡,未开通</span></td>
                </tr>
                <tr>
                    <td>操作</td>
                    <td><button class="offlineBuy btn" id="{$vip['vip_id']}" shopId="{$shopId}">线下购买</button>
                        <button class="onlineOpen btn" id="{$vip['vip_id']}">线上开通</button></td>
                </tr>
            </table>

            <elseif condition="$status eq 1"/>

            <table class="table table-hover table-bordered">
                <tr>
                    <th colspan='2'>店铺与会员卡信息</th>
                </tr>
                <tr>
                    <td>会员卡状况</td>
                    <td>
                        <span style="color: red;">已购买,未开通</span></td>
                </tr>
                <tr>
                    <td>操作</td>
                    <td>
                        <button class="offlineBuy btn" id="{$vip['vip_id']}" shopId="{$shopId}">线下购买</button>
                        <button class="onlineOpen btn" id="{$vip['vip_id']}">线上开通</button></td>
                </tr>
            </table>

            <table class="table table-hover table-bordered">
                <thead>
                    <tr>
                        <th colspan="9">
                            线下待开通的会员卡
                        </th>
                    </tr>
                    <tr>                       
                        <th>编号</th>
                        <th>店铺</th>
                        <th>推荐人员</th>
                        <th>会员卡类型</th>
                        <th>支付方式</th>
                        <th>渠道</th>
                        <th>时长</th>
                        <th>价格</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <empty name="orderList">
                    <tr>                       
                        <th><span style="color: red;">待开通的会员卡为空!</span></th>
                    </tr>                        
                    <else /> 
                    <tbody>
                    <foreach name="orderList" item="vo">
                        <tr>
                            <td>{$vo.order_id}</td>
                            <td>{$vo.shop_name}</td>
                            <td>{$vo.sale_name}</td>
                            <td>{:getEnumString($buytype, $vo['buy_type'])}</td>
                            <td>{:getEnumString($paytype, $vo['pay_type'])}</td>
                            <td>{:getEnumString($channel, $vo['channel'])}</td>
                            <td>{$vo.term_number}&nbsp;{:getEnumString($buytype, $vo['buy_type'])}</td>
                            <td>{$vo.price} 元</td>
                            <td>
                                <button class="offlineOpenPre btn" id="{$vo['order_id']}">立即开通</button>
                            </td>
                        </tr>
                    </foreach>
                    </tbody>
                </empty>
            </table>
            <else/>            

            <table class="table table-hover table-bordered">
                <tr>
                    <th colspan='4'>店铺与会员卡信息</th>
                </tr>
                <tr>
                    <td>店铺</td>
                    <td>{$relationship.shop_name}</td>
                    <td>未签出次数</td>
                    <td>
                        <span style="color: red;font-weight:bold;">{$relationship.not_checkout_num}</span></td>
                </tr>
                <tr>
                    <td>会员卡状况</td>
                    <td>
                        <span style="color: red;font-weight:bold;">{:getEnumString($cardstatus, $relationship['status'])}</span></td>
                    <td>会员卡有效期</td>
                    <td>
                        <span style="color: red;font-weight:bold;">{$relationship.total} 个月</span></td>
                </tr>
                <tr>
                    <td>已锻炼时间</td>
                    <td>
                        <span style="font-weight:bold;">{$relationship.done} 个月</span></td>
                    <td>剩余时间</td>
                    <td>
                        <span style="font-weight:bold;">{$relationship.remain} 个月</span></td>
                </tr>
                <tr>
                    <td>创建时间</td>
                    <td>{$relationship.create_time}</td>
                    <td>截止时间</td>
                    <td>{$relationship.end_time}</td>
                </tr>
                <tr>
                    <td>指纹</td>
                    <td>{$relationship.finger}</td>
                    <td>卡号</td>
                    <td>{$relationship.card_number}</td>
                </tr>

                <tr>
                    <td>线下操作</td>
                    <td >
                        <button class="offlineBuy btn" id="{$vip['vip_id']}" shopId="{$shopId}">线下购买</button>
                    </td>
                    <td>线上操作</td>
                    <td >
                        <button class="onlineOpen btn" id="{$vip['vip_id']}">线上开通</button>
                    </td>
                </tr>
            </table>

            <table class="table table-hover table-bordered">
                <thead>
                    <tr>
                        <th colspan="8">
                            线下待开通的会员卡
                        </th>
                        <th>
                            <button class="myVipRecord btn" id="{$vip['vip_id']}" shopId="{$shopId}">开通记录</button></th>
                    </tr>
                    <tr>                       
                        <th>编号</th>
                        <th>店铺</th>
                        <th>推荐人员</th>
                        <th>会员卡类型</th>
                        <th>支付方式</th>
                        <th>渠道</th>
                        <th>时长</th>
                        <th>价格</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <empty name="orderList">
                    <tr>                       
                        <th colspan='9'><span style="color: red;">线下待开通的会员卡为空!</span></th>
                    </tr>                        
                    <else /> 
                    <tbody>
                    <foreach name="orderList" item="vo">
                        <tr>
                            <td>{$vo.order_id}</td>
                            <td>{$vo.shop_name}</td>
                            <td>{$vo.sale_name}</td>
                            <td>{:getEnumString($buytype, $vo['buy_type'])}</td>
                            <td>{:getEnumString($paytype, $vo['pay_type'])}</td>
                            <td>{:getEnumString($channel, $vo['channel'])}</td>
                            <td>{$vo.term_number}&nbsp;{:getEnumString($buytype, $vo['buy_type'])}</td>
                            <td>{$vo.price} 元</td>
                            <td>
                                <button class="offlineOpenPre btn" id="{$vo['order_id']}">立即开通</button>
                            </td>
                        </tr>
                    </foreach>
                    </tbody>
                </empty>
            </table>
            <notempty name="isValid">                                   

                <table class="table table-hover table-bordered">
                    <thead>
                        <tr>
                            <th colspan='3'>私教课基本信息</th>
                            <th colspan='2'><button class="buyCourse btn" id="{$vip['vip_id']}" shopId='{$shopId}'>购买私教课</button></th>
                            <th colspan='2'><button class="viewBindingCoach btn" id="{$vip['vip_id']}" shopId='{$shopId}'>预约教练</button></th>
                        </tr>
                        <tr>
                            <th>编号</th>
                            <th>店铺</th>
                            <th>教练名称</th>
                            <th>剩余课程</th>
                            <th>总上课次数</th>
                            <th>待上课次数</th>
                            <th>预约</th>
                        </tr>
                    </thead>
                    <empty name="courseList">
                        <tr>
                            <th colspan='7'><span style="color: red;">私教课记录为空!</span></th>
                        </tr>           
                        <else />
                        <tbody>
                        <foreach name="courseList" item="vo">
                            <tr>
                                <td>{$vo.course_id}</td>
                                <td>{$vo.shop_name}</td>
                                <td>{$vo.coach_name}</td>
                                <td>{$vo.left_class_number} 节</td>
                                <td>{$vo.total_class_number} 节</td>
                                <td>{$vo.wait_class_number} 节</td>
                                <td>
                            <if condition='$vo.left_class_number egt 1'>
                                <button class="bookCoachTime btn" id="{$vo['course_id']}">预约</button>
                                <else/>

                            </if>
                            </td>
                            </tr>
                        </foreach>
                        </tbody>
                    </empty>
                </table>
                <table class="table table-hover table-bordered">
                    <thead>
                        <tr>
                            <th colspan="4">最近待上课记录</th>
                            <th colspan="1" width='15%'><button class="viewAllClassRecord btn" id="{$vip['vip_id']}" shopId="{$shopId}">更多课程记录</button></th>
                        </tr>
                        <tr>          
                            <th>编号</th>
                            <th>店铺</th>
                            <th>教练</th>
                            <th>上课日期</th>
                            <th>时间</th>
                        </tr>
                    </thead>
                    <empty name="recordList">
                        <tr>
                            <th colspan='5'><span style="color: red;">待上课记录为空!</span></th>
                        </tr>           
                        <else /> 
                        <tbody>
                        <foreach name="recordList" item="vo">
                            <tr>
                                <td>{$vo.record_id}</td>
                                <td>{$vo.shop_name}</td>
                                <td>{$vo.coach_name}</td>
                                <td>{$vo.date}</td>
                                <td>{$vo.booking_time} 点</td>
                            </tr>
                        </foreach>
                        </tbody>
                    </empty>
                </table>
            </notempty>  
        </if>        
    </div>
</if>

<script src="__ROOT__/statics/js/common.js"></script>
</body>
</html>